var orderTable;
function getOrderList() {
    if (orderTable) {
        orderTable.fnPageChange('first');
        return;
    }
    var i = 1;
    orderTable = $("#orderList").DataTable({
        "sAjaxSource": _path + "/order/findOrders?orderType="+$("#type").val(),//服务端地址
        "fnServerParams": function (aoData) {               //ajax请求参数
            aoData.push(
                { "name": "id", "value": $("#orderNo").val() },
                { "name": "goodsName", "value": $("#goodsName").val() },
                { "name": "status", "value": $("#status").val() },
                { "name": "fromDate", "value": $("#fromDate").val() },
                { "name": "toDate", "value": $("#toDate").val() }
//                ,{ "name": "keyType", "value": $("#keyType").val() },
//                { "name": "keywords", "value": $("#keywords").val() }
            );
        },
        "sServerMethod": "POST",    //请求方式
        "sAjaxDataProp": "dataList",//服务端返回的数据名
        "fnCreatedRow": function () {
            i++;
        },
        "fnPreDrawCallback": function () {
            i = 1;
        },
        "aoColumns": [              //列（table显示的内容）
            { "sTitle": "序号", "sWidth": "2%",
                "mData": function () {
                    return i;
                }
            },
            { "sTitle": "订单号", "mData": "id", "sWidth": "15%" },
            { "sTitle": "商品名称", "sWidth": "15%",
                "mData": function (obj) {
                    return obj.orderType==="2"?'充值':'<a href="javascript:window.open(\'http://www.sjwangwang.com/business/detail/'+obj.goodsNo+'\')">'+obj.goodsName+'</a>';
                }
            },
            { "sTitle": "订单金额", "mData": "amount", "sWidth": "10%" },
            { "sTitle": "S币", "mData": "sMoney", "sWidth": "10%" },
            { "sTitle": "用户", "sWidth": "15%",
                "mData": function (obj) {
                    return '<a href="javascript:window.open(\''+_path+'/member/edit/'+obj.userId+'\')">'+(obj.userName?obj.userName:'')+'</a>';
                }
            },
            { "sTitle": "订单时间", "mData": "orderDate", "sWidth": "10%" },
            { "sTitle": "状态", "mData": "status", "sWidth": "10%",
                "mRender": function (data, type, full) {
                    var status = '';
                    switch (data) {
                        case '1':
                            status = "成功";
                            break;
                        case '2':
                            status = "失败";
                            break;
                        case '3':
                            status = "撤销";
                            break;
                        case '4':
                            status = "未支付";
                            break;
                        default:
                            break;
                    }
                    return status;
                }}
        ]
    });
}